/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var subarraySum = function(nums, k) {
    let count=0
    let n=nums.length
    let prefix=0
    let map={0:1}
    for(let i=0;i<n;i++){
        prefix+=nums[i]
        if(map[prefix-k]){
            count+=map[prefix-k]
        }
        if(map[prefix]){
            map[prefix]++
        }
        else{
            map[prefix]=1
        }

    }
    return count
};

let nums = [1,2,3]
let k = 3
console.log(subarraySum(nums,k));